package br.com.translog.modelo;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "\"PessoaJuridica\"", catalog = "\"Translog\"", schema = "\"EsqTranslog\"")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PessoaJuridica.findAll", query = "SELECT p FROM PessoaJuridica p"),
    @NamedQuery(name = "PessoaJuridica.findByCodigo", query = "SELECT p FROM PessoaJuridica p WHERE p.codigo = :codigo"),
    @NamedQuery(name = "PessoaJuridica.findByRazaoSocial", query = "SELECT p FROM PessoaJuridica p WHERE p.razaoSocial = :razaoSocial"),
    @NamedQuery(name = "PessoaJuridica.findByNomeFantasia", query = "SELECT p FROM PessoaJuridica p WHERE p.nomeFantasia = :nomeFantasia"),
    @NamedQuery(name = "PessoaJuridica.findByCnpj", query = "SELECT p FROM PessoaJuridica p WHERE p.cnpj = :cnpj"),
    @NamedQuery(name = "PessoaJuridica.findByTelefoneComercial", query = "SELECT p FROM PessoaJuridica p WHERE p.telefoneComercial = :telefoneComercial"),
    @NamedQuery(name = "PessoaJuridica.findBySite", query = "SELECT p FROM PessoaJuridica p WHERE p.site = :site"),
    @NamedQuery(name = "PessoaJuridica.findByEmail", query = "SELECT p FROM PessoaJuridica p WHERE p.email = :email")})
public class PessoaJuridica implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "\"Codigo\"")
    private Integer codigo;
    @Basic(optional = false)
    @Column(name = "\"RazaoSocial\"")
    private String razaoSocial;
    @Basic(optional = false)
    @Column(name = "\"NomeFantasia\"")
    private String nomeFantasia;
    @Basic(optional = false)
    @Column(name = "\"CNPJ\"")
    private long cnpj;
    @Basic(optional = false)
    @Column(name = "\"TelefoneComercial\"")
    private long telefoneComercial;
    @Column(name = "\"Site\"")
    private String site;
    @Column(name = "\"Email\"")
    private String email;
    @OneToOne(mappedBy = "codigoPessoaJuridica")
    private Cliente cliente;
    @OneToOne(mappedBy = "codigoPessoaJuridica")
    private Fornecedor fornecedor;

    public PessoaJuridica() {
    }

    public PessoaJuridica(Integer codigo) {
        this.codigo = codigo;
    }

    public PessoaJuridica(Integer codigo, String razaoSocial, String nomeFantasia, long cnpj, long telefoneComercial) {
        this.codigo = codigo;
        this.razaoSocial = razaoSocial;
        this.nomeFantasia = nomeFantasia;
        this.cnpj = cnpj;
        this.telefoneComercial = telefoneComercial;
    }

    public Integer getCodigo() {
        return codigo;
    }

    public void setCodigo(Integer codigo) {
        this.codigo = codigo;
    }

    public String getRazaoSocial() {
        return razaoSocial;
    }

    public void setRazaoSocial(String razaoSocial) {
        this.razaoSocial = razaoSocial;
    }

    public String getNomeFantasia() {
        return nomeFantasia;
    }

    public void setNomeFantasia(String nomeFantasia) {
        this.nomeFantasia = nomeFantasia;
    }

    public long getCnpj() {
        return cnpj;
    }

    public void setCnpj(long cnpj) {
        this.cnpj = cnpj;
    }

    public long getTelefoneComercial() {
        return telefoneComercial;
    }

    public void setTelefoneComercial(long telefoneComercial) {
        this.telefoneComercial = telefoneComercial;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public Fornecedor getFornecedor() {
        return fornecedor;
    }

    public void setFornecedor(Fornecedor fornecedor) {
        this.fornecedor = fornecedor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PessoaJuridica)) {
            return false;
        }
        PessoaJuridica other = (PessoaJuridica) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.translog.modelo.PessoaJuridica[ codigo=" + codigo + " ]";
    }
}
